package com.batata.continuing.web.common;

import com.batata.continuing.config.moreNote.token.NotNeedToken;
import com.batata.continuing.pojo.base.ResultData;
import com.batata.continuing.pojo.config.ConfigSwitch;
import com.batata.continuing.service.config.ConfigSwitchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "配置相关的接口")
@RestController
@RequestMapping("/tree")
public class ConfigController {


    @Autowired
    private ConfigSwitchService switchService;


    @NotNeedToken
    @ApiOperation("更新开关的配置")
    @PostMapping("/updateSwitchConfig")
    public ResultData<Object> updateSwitchConfig() {
        return switchService.updateSwitchConfig();
    }

    @ApiOperation("修改开关的配置")
    @PostMapping("/alterSwitchConfig")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "要修改的配置id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "openOrClose", value = "结果 0 关 1 开", required = true, dataType = "String")
    })
    public ResultData<Object> alterSwitchConfig(ConfigSwitch configSwitch) {
        return switchService.alterSwitchConfig(configSwitch);
    }


}
